/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('geoip', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model DescribeGeoipInstanceRequest {
  lang?: string(name='Lang'),
  instanceId?: string(name='InstanceId'),
}

model DescribeGeoipInstanceResponseBody = {
  expireTimestamp?: long(name='ExpireTimestamp'),
  versionCode?: string(name='VersionCode'),
  maxQpd?: long(name='MaxQpd'),
  maxQps?: long(name='MaxQps'),
  requestId?: string(name='RequestId'),
  instanceId?: string(name='InstanceId'),
  productCode?: string(name='ProductCode'),
  createTime?: string(name='CreateTime'),
  queryCount?: long(name='QueryCount'),
  expireTime?: string(name='ExpireTime'),
  createTimestamp?: long(name='CreateTimestamp'),
}

model DescribeGeoipInstanceResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeGeoipInstanceResponseBody(name='body'),
}

async function describeGeoipInstanceWithOptions(request: DescribeGeoipInstanceRequest, runtime: Util.RuntimeOptions): DescribeGeoipInstanceResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeGeoipInstance', '2020-01-01', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeGeoipInstance(request: DescribeGeoipInstanceRequest): DescribeGeoipInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeGeoipInstanceWithOptions(request, runtime);
}

model DescribeGeoipInstanceDataInfosRequest {
  lang?: string(name='Lang'),
  instanceId?: string(name='InstanceId'),
  locationDataType?: string(name='LocationDataType'),
}

model DescribeGeoipInstanceDataInfosResponseBody = {
  requestId?: string(name='RequestId'),
  dataInfos?: {
    dataInfo?: [ 
    {
      type?: string(name='Type'),
      updateTimestamp?: long(name='UpdateTimestamp'),
      updateTime?: string(name='UpdateTime'),
      version?: string(name='Version'),
      downloadCount?: long(name='DownloadCount'),
    }
  ](name='DataInfo')
  }(name='DataInfos'),
}

model DescribeGeoipInstanceDataInfosResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeGeoipInstanceDataInfosResponseBody(name='body'),
}

async function describeGeoipInstanceDataInfosWithOptions(request: DescribeGeoipInstanceDataInfosRequest, runtime: Util.RuntimeOptions): DescribeGeoipInstanceDataInfosResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeGeoipInstanceDataInfos', '2020-01-01', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeGeoipInstanceDataInfos(request: DescribeGeoipInstanceDataInfosRequest): DescribeGeoipInstanceDataInfosResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeGeoipInstanceDataInfosWithOptions(request, runtime);
}

model DescribeGeoipInstanceDataUrlRequest {
  lang?: string(name='Lang'),
  instanceId?: string(name='InstanceId'),
  dataType?: string(name='DataType'),
}

model DescribeGeoipInstanceDataUrlResponseBody = {
  requestId?: string(name='RequestId'),
  downloadUrl?: string(name='DownloadUrl'),
  fixedDomainDownloadUrl?: string(name='FixedDomainDownloadUrl'),
}

model DescribeGeoipInstanceDataUrlResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeGeoipInstanceDataUrlResponseBody(name='body'),
}

async function describeGeoipInstanceDataUrlWithOptions(request: DescribeGeoipInstanceDataUrlRequest, runtime: Util.RuntimeOptions): DescribeGeoipInstanceDataUrlResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeGeoipInstanceDataUrl', '2020-01-01', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeGeoipInstanceDataUrl(request: DescribeGeoipInstanceDataUrlRequest): DescribeGeoipInstanceDataUrlResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeGeoipInstanceDataUrlWithOptions(request, runtime);
}

model DescribeGeoipInstancesRequest {
  lang?: string(name='Lang'),
}

model DescribeGeoipInstancesResponseBody = {
  requestId?: string(name='RequestId'),
  geoipInstances?: {
    geoipInstance?: [ 
    {
      status?: string(name='Status'),
      expireTimestamp?: long(name='ExpireTimestamp'),
      expireTime?: string(name='ExpireTime'),
      maxQps?: long(name='MaxQps'),
      createTime?: string(name='CreateTime'),
      maxQpd?: long(name='MaxQpd'),
      instanceId?: string(name='InstanceId'),
      versionCode?: string(name='VersionCode'),
      createTimestamp?: long(name='CreateTimestamp'),
      productCode?: string(name='ProductCode'),
    }
  ](name='GeoipInstance')
  }(name='GeoipInstances'),
}

model DescribeGeoipInstancesResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeGeoipInstancesResponseBody(name='body'),
}

async function describeGeoipInstancesWithOptions(request: DescribeGeoipInstancesRequest, runtime: Util.RuntimeOptions): DescribeGeoipInstancesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeGeoipInstances', '2020-01-01', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeGeoipInstances(request: DescribeGeoipInstancesRequest): DescribeGeoipInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeGeoipInstancesWithOptions(request, runtime);
}

model DescribeGeoipInstanceStatisticsRequest {
  lang?: string(name='Lang'),
  instanceId?: string(name='InstanceId'),
  startDate?: string(name='StartDate'),
  endDate?: string(name='EndDate'),
}

model DescribeGeoipInstanceStatisticsResponseBody = {
  requestId?: string(name='RequestId'),
  statistics?: {
    statistic?: [ 
    {
      timestamp?: long(name='Timestamp'),
      count?: long(name='Count'),
    }
  ](name='Statistic')
  }(name='Statistics'),
}

model DescribeGeoipInstanceStatisticsResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeGeoipInstanceStatisticsResponseBody(name='body'),
}

async function describeGeoipInstanceStatisticsWithOptions(request: DescribeGeoipInstanceStatisticsRequest, runtime: Util.RuntimeOptions): DescribeGeoipInstanceStatisticsResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeGeoipInstanceStatistics', '2020-01-01', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeGeoipInstanceStatistics(request: DescribeGeoipInstanceStatisticsRequest): DescribeGeoipInstanceStatisticsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeGeoipInstanceStatisticsWithOptions(request, runtime);
}

model DescribeIpv4LocationRequest {
  lang?: string(name='Lang'),
  ip?: string(name='Ip'),
}

model DescribeIpv4LocationResponseBody = {
  provinceEn?: string(name='ProvinceEn'),
  requestId?: string(name='RequestId'),
  cityEn?: string(name='CityEn'),
  ip?: string(name='Ip'),
  isp?: string(name='Isp'),
  latitude?: string(name='Latitude'),
  city?: string(name='City'),
  county?: string(name='County'),
  longitude?: string(name='Longitude'),
  countryEn?: string(name='CountryEn'),
  province?: string(name='Province'),
  country?: string(name='Country'),
  countryCode?: string(name='CountryCode'),
}

model DescribeIpv4LocationResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeIpv4LocationResponseBody(name='body'),
}

async function describeIpv4LocationWithOptions(request: DescribeIpv4LocationRequest, runtime: Util.RuntimeOptions): DescribeIpv4LocationResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeIpv4Location', '2020-01-01', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeIpv4Location(request: DescribeIpv4LocationRequest): DescribeIpv4LocationResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeIpv4LocationWithOptions(request, runtime);
}

model DescribeIpv6LocationRequest {
  lang?: string(name='Lang'),
  ip?: string(name='Ip'),
}

model DescribeIpv6LocationResponseBody = {
  provinceEn?: string(name='ProvinceEn'),
  requestId?: string(name='RequestId'),
  cityEn?: string(name='CityEn'),
  ip?: string(name='Ip'),
  isp?: string(name='Isp'),
  latitude?: string(name='Latitude'),
  city?: string(name='City'),
  county?: string(name='County'),
  longitude?: string(name='Longitude'),
  countryEn?: string(name='CountryEn'),
  province?: string(name='Province'),
  country?: string(name='Country'),
  countryCode?: string(name='CountryCode'),
}

model DescribeIpv6LocationResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeIpv6LocationResponseBody(name='body'),
}

async function describeIpv6LocationWithOptions(request: DescribeIpv6LocationRequest, runtime: Util.RuntimeOptions): DescribeIpv6LocationResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeIpv6Location', '2020-01-01', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeIpv6Location(request: DescribeIpv6LocationRequest): DescribeIpv6LocationResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeIpv6LocationWithOptions(request, runtime);
}

